package practice.hot100;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class Solution45 {
    public int jump(int[] nums) {
        if (nums.length == 1) return 0;
        int count = 0;
        int cover = 0;
        int index = 0;
        for (int i = 0; i < nums.length; i++) {
            cover = Math.max(cover, nums[i] + i);
            if (cover >= nums.length - 1) {
                count++;
                return count;
            }
            if (i == index) {
                count++;
                index = cover;
            }
        }
        return count;
    }
}
